*** Settings ***
Library           RequestsLibrary
Library           JSONLibrary
Resource          ../common/common.robot
Resource          ../goods/goods.robot
Resource           ../design/design.robot
Resource    ../design/order.robot


*** Test Cases ***
Test Case: 测试设计款保存面辅料中的供应商信息
    Login Admin Account
    # 准备数据
    ${data}    Load JSON from file      ./DEF-17106/data/add-data.json     UTF-8
    ${designSn}  evaluate  random.randint(1000,9999)          #生成随机的设计款sn
    ${data}    Update value to JSON     ${data}     $.design.designSn      ${designSn}
    # 确保数据库至少有一个数据
    ${data}     Save Design    ${data}
    ${design_id}        Get Value From Json    ${data}    $.design.id
    ${data}     Get Design      ${design_id[0]}
    # 取出供应商信息
    ${designMaterialDevs}    Get Value From Json    ${data}    $.designMaterialDevs
    Log     ${designMaterialDevs}
    FOR    ${element}    IN    @{designMaterialDevs[0]}
        Should Be Equal As Strings    ${element['supplierInfo']}    测试供应商信息
    END
    # 删除设计款
    Delete Design   ${design_id[0]}

Test Case: 测试新增版单查看版单中是否存在设计款中面辅料信息
    Login Admin Account
    # 准备数据
    ${data}    Load JSON from file      ./DEF-17106/data/add-data.json     UTF-8
    ${designSn}  evaluate  random.randint(1000,9999)          #生成随机的设计款sn
    ${data}    Update value to JSON     ${data}     $.design.designSn      ${designSn}
    # 确保数据库至少有一个数据
    ${data}     Save Design    ${data}
    ${design_id}        Get Value From Json    ${data}    $.design.id
    ${data}     Get Design      ${design_id[0]}
    # 取出供应商信息
    ${designMaterialDevs}    Get Value From Json    ${data}    $.designMaterialDevs
    Log     ${designMaterialDevs}
    FOR    ${element}    IN    @{designMaterialDevs[0]}
        Should Be Equal As Strings    ${element['supplierInfo']}    测试供应商信息
    END
    # 根据该设计款新增版单
    ${data}    Load JSON from file      ./DEF-17106/data/add-design-order.json     UTF-8
    ${designOrderSn}  evaluate  random.randint(1000,9999)          #生成随机的设计款sn
    ${data}    Update value to JSON     ${data}     $.designOrder.designOrderSn      ${designOrderSn}
    ${data}     Update Value To Json    ${data}    $.designOrder.designId    ${design_id[0]}
    ${design_order_data}    Save Design Order   ${data}

    # 获得这个版单
    ${design_order_id}    Get Value From Json    ${design_order_data}    $.designOrder.id
    ${design_order_data}    Get Design Order    ${design_order_id[0]}
    ${designMaterialDevs}    Get Value From Json    ${design_order_data}    $.designOrderMaterialDevs
    Log     ${designMaterialDevs}
    FOR    ${element}    IN    @{designMaterialDevs[0]}
        Should Be Equal As Strings    ${element['supplierInfo']}    测试供应商信息
    END